import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:前缀和
 * User: bjc
 * Date: 2025-11-18
 * Time: 16:30
 */
public class Test01_prefixSum {
    public static void main(String[] args) {
        //1.读入数据
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = scanner.nextInt();
        }
        //2.预处理一个前缀和数组,防止溢出，所以使用long类型
        long[] tmp = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            tmp[i] = tmp[i - 1] + arr[i];
        }
        //3.读取区间范围
        while (m != 0) {
            int l = scanner.nextInt();
            int r = scanner.nextInt();
            long ret = tmp[r] - tmp[l - 1];
            System.out.println(ret);
            m--;
        }
    }
}
